<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
	<script type="text/javascript">
		window.onload=function (){
		/*var oTab=document.getElementById('tab1');
		var a=oTab.getElementsByTagName('tbody')[0];
		var b=a.getElementsByTagName('tr')[1];
		var c=b.getElementsByTagName('td')[1];
         alert(c.innerHTML);*/
         //行rows   单元格列cells
        /* var oTab=document.getElementById('tab1');
         alert(oTab.tBodies[0].rows[1].cells[1].innerHTML);*/
         var oTab=document.getElementById("tab1");
         var oldColor="";
         for(var i=0;i<oTab.tBodies[0].rows.length;i++){
         	oTab.tBodies[0].rows[i].onmouseover=function (){
         		oldColor=this.style.background;
         		this.style.background="green";
         	}
         	oTab.tBodies[0].rows[i].onmouseout=function (){
         		this.style.background=oldColor;
         	}
         	if(i%2){
         		oTab.tBodies[0].rows[i].style.background="#ccc";
         	}else{
         		oTab.tBodies[0].rows[i].style.background="";
         	}
         }
		}
	</script>
</head>
<body>
	<table id="tab1" border="1" width="500">
	<thead>
		<td>ID</td>
		<td>姓名</td>
		<td>年龄</td>
		<td>操作</td>
	</thead>
	<tbody>
		<tr>
			<td>1</td>
			<td>Blue</td>
			<td>28</td>
			<td></td>
		</tr>
		<tr>
			<td>2</td>
			<td>张三</td>
			<td>23</td>
			<td></td>
		</tr>
		<tr>
			<td>3</td>
			<td>王五</td>
			<td>22</td>
			<td></td>
		</tr>
		<tr>
			<td>4</td>
			<td>小二</td>
			<td>28</td>
			<td></td>
		</tr>
		<tr>
			<td>5</td>
			<td>许二</td>
			<td>28</td>
			<td></td>
		</tr>
	</tbody>
</body>
</html>